class Person:
    nums = 0  # 类属性，所有的对象共用一个值
    min_age = 0
    # 构造函数,每次创建对象的时候都会被调用
    def __init__(self,name,age,city):
        self.name = name
        if age < Person.min_age:
            raise Exception("年龄不能小于设置的最小值0")
        else:
            self.age = age
        self.city = city
        Person.nums +=1


p1 = Person("张三",20,"上海")
print(Person.nums)
p2 = Person("lisi",21,"beijing")
print(Person.nums)
print(p1.__dict__)